import React, { Component } from 'react'
// import qs from 'querystring' // npm i querystring

export default class Detail extends Component {

   
   
  render() { 
     const DetailData = [{
        id:'01',content:'你好',
    },{
id:'02',content:'你好中国',
    },{
id:'03',content:'你好未来的自己'
    }]
    //1.接收param参数
    // const params = this.props.match.params
    // console.log(params);// 最终结果
    // const endData = params


// 2.接收search参数
// const search = this.props.location.search
// console.log(qs.parse(search.slice(1)));
// const endSearch = qs.parse(search.slice(1))// 最终结果

// const endData = endSearch

// 3.接收state参数 history模式刷新参数不丢失 hash刷新页面参数丢失
const stateData = this.props.location.state || {}
console.log(stateData);
const endData = stateData

    const findContent = DetailData.find((dataObj)=>{
return dataObj.id === endData.id
    })
    return (
        <div>
          <div>{endData.id}</div>
      <div>{endData.title}</div>
      <div>{findContent.content}</div>
      </div>
      
    )
  }
}
